package com.yunshan.mp;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yunshan.common.annotation.Log;
import com.yunshan.common.core.controller.BaseController;
import com.yunshan.common.core.domain.AjaxResult;
import com.yunshan.common.enums.BusinessType;
import com.yunshan.mp.domain.MpServeType;
import com.yunshan.mp.service.IMpServeTypeService;
import com.yunshan.common.utils.poi.ExcelUtil;
import com.yunshan.common.core.page.TableDataInfo;

/**
 * 服务类型Controller
 * 
 * @author yunshan
 * @date 2025-02-27
 */
@RestController
@RequestMapping("/mp/serveType")
public class MpServeTypeController extends BaseController
{
    @Autowired
    private IMpServeTypeService mpServeTypeService;

    /**
     * 查询服务类型列表
     */
    @GetMapping("/list")
    @PreAuthorize("@ss.hasPermi('mp:serve:list')")
    public AjaxResult list()
    {
        MpServeType mpServeType = new MpServeType();
        mpServeType.setStatus(0);
        List<MpServeType> list = mpServeTypeService.selectMpServeTypeList(mpServeType);
        return success(list);
    }

    /**
     * 导出服务类型列表
     */
    @Log(title = "服务类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MpServeType mpServeType)
    {
        List<MpServeType> list = mpServeTypeService.selectMpServeTypeList(mpServeType);
        ExcelUtil<MpServeType> util = new ExcelUtil<MpServeType>(MpServeType.class);
        util.exportExcel(response, list, "服务类型数据");
    }

    /**
     * 获取服务类型详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(mpServeTypeService.selectMpServeTypeById(id));
    }

    /**
     * 新增服务类型
     */
    @Log(title = "服务类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MpServeType mpServeType)
    {
        return toAjax(mpServeTypeService.insertMpServeType(mpServeType));
    }

    /**
     * 修改服务类型
     */
    @Log(title = "服务类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MpServeType mpServeType)
    {
        return toAjax(mpServeTypeService.updateMpServeType(mpServeType));
    }

    /**
     * 删除服务类型
     */
    @Log(title = "服务类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mpServeTypeService.deleteMpServeTypeByIds(ids));
    }
}
